﻿using System.Text.Json;

namespace XiaofangExam.ServiceApi
{
    public class KaoshiApi
    {
        public static async Task<TData<List<ShitiEntity>>> Search(string keyword)
        {
            string url = "http://api.kaoshi.sdsnwl.com/kaoshi/search?keyword=" + keyword;
            HttpClient client = new HttpClient();
            var response = await client.GetAsync(url);
            if (response.IsSuccessStatusCode)
            {
                string result = response.Content.ReadAsStringAsync().Result;
                return JsonSerializer.Deserialize<TData<List<ShitiEntity>>>(result);
            }
            return null;
        }
    }
}
